  <template>
  <div class="page-3 f-r f-g">
    <el-row :gutter="16" style="width: 100%;height: 100%">
      <el-col :span="6">
        <div class="left-card">
          <div class="card-header f-r a-c j-b">
            <div class="card-title" style="font-size: 16px">选择地图建模</div>
            <el-upload :show-file-list="false">
              <el-button type="primary">批量上传</el-button>
            </el-upload>
          </div>
          <div class="card-body">
            <div class="file-list">
              <div
                  :class="['file-item f-r a-c', activeFile.id === item.id ? 'active' : '']" v-for="item in fileList" :key="item.id">
                <div class="f-g f-r a-c"   @click="handleClickFile(item)">
                  <div class="file-image">
                    <img :src="item.cover" alt="">
                  </div>
                  <div class="file-detail f-g">
                    <div class="file-name">{{ item.name }}</div>
                    <div class="file-size">{{ item.size }}</div>
                  </div>
                </div>
                <el-popconfirm title="是否确认删除?" @confirm="deleteFile(item)">
                  <template #reference>
                    <el-icon style="cursor:pointer" color="#D9D9D9" :size="24"><CircleCloseFilled /></el-icon>
                  </template>
                </el-popconfirm>
              </div>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="18">
        <div class="right-card" id="threeMap">
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script setup>
import {onMounted, onUnmounted, ref} from "vue";
import { CircleCloseFilled, VideoPlay, CopyDocument, Delete, ArrowRight } from "@element-plus/icons-vue";
import AMapLoader from "@amap/amap-jsapi-loader";
import {MapKey} from "@/plugins/amap";
const fileList = ref([
  {
    id: 1,
    cover: require('@/assets/other/zip_icon.png'),
    name: '文件名称',
    size: '300kb'
  },
  {
    id: 2,
    cover: require('@/assets/other/zip_icon.png'),
    name: '文件名称',
    size: '300kb'
  }
])
const activeFile = ref({
  id: 1
})
const deleteFile = (item) => {
  console.log(item)
}

/**
 * 地图
 */
let map = null;
onMounted(() => {
  AMapLoader.load({
    key: MapKey, // 申请好的Web端开发者Key，首次调用 load 时必填
    version: "2.0", // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
    plugins: [], // 需要使用的的插件列表，如比例尺'AMap.Scale'等
  })
      .then((AMap) => {
        map = new AMap.Map("threeMap", {
          // 设置地图容器id
          viewMode: "3D", // 是否为3D地图模式
          zoom: 14, // 初始化地图级别
          center: [116.397428, 39.90923], // 初始化地图中心点位置
        });
      })
      .catch((e) => {
        console.log(e);
      });
})
const handleClickFile = (row) => {
  activeFile.value = row
}

onUnmounted(() => {
  map?.destroy();
});
</script>

<style lang="scss">
.page-3 {
  height: 100%;
  padding: 16px;
  overflow: auto;
  .left-card {
    height: 100%;
    background-color: #ffffff;
    border-radius: 16px;
    .card-header {
      padding: 20px;
      border-bottom: 1px solid #F2F2F2;
    }
  }
  .card-body {
    padding: 10px 0;
    .file-list {
      .file-item {
        padding: 10px 20px;
        cursor: pointer;
        &.active {
          background: rgba(0,0,0,.03);
          .file-detail .file-name {
            color: #17BDB2;
          }
        }
        .file-image {
          position: relative;
          margin-right: 16px;
          img {
            width: 44px;
            border-radius: 8px;
          }
          .play-icon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 1;
          }
        }
        .file-detail {
          height: 100%;
          .file-name {
            font-family: Source Han Sans CN;
            font-weight: 400;
            font-size: 16px;
            color: #666666;
            margin-bottom: 6px;
          }
          .file-size {
            font-family: Source Han Sans CN;
            font-weight: 400;
            font-size: 14px;
            color: #CCCCCC;
          }
        }
        .file-status {
          padding: 0 20px;
          width: 160px;
          .status-item1 {
            color: #17BDB2;
          }
          .status-item2 {
            color: #F94C4C;
          }
        }
        .file-desc {
          font-family: Source Han Sans CN;
          font-weight: 400;
          font-size: 14px;
          color: #999999;
          line-height: 23px;
          padding-right: 50px;
        }
      }
    }
  }
  .right-card {
    height: 100%;
    background-color: #ffffff;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
  }
}

</style>